'use strict'

const _ = require('lodash')
const moment = require('moment')
const Env = use('Env')
const { AliYunService } = require('../../Services')
const { FaNews,FaMp4 } = require("../../Models");
class VideoController {
  async index({request, response}) {
    let { page = 1, pageSize = 10, searchWord,year } = request.all()
    let query = FaMp4.query()
    if (year=='2020') {
      query.where('publishtime','<=','2020-12-31 23:59:59')
    } else if (year=='2021') {
      query.where('publishtime','>','2020-12-31 23:59:59')
    }
    let coll = await query.paginate(page, pageSize)
    response.json(coll)
  }
  async show({request, response, params}) {
    console.log('params: ', params);
    let coll = await FaMp4.find(params.id)
    response.json(coll)
  }
}
module.exports = VideoController